﻿#include "enemyplane.h"
#include "config.h"

EnemyPlane::EnemyPlane()
{
    enemy.load(":/res/enemy.png");
    postion_x = 0;
    postion_y = 0;
    isFree = true;
    speed = 5;

    enemyRect.setWidth(enemy.width());
    enemyRect.setHeight(enemy.height());
    enemyRect.moveTo(postion_x,postion_y);
}

QPixmap EnemyPlane::getEnemy() const
{
    return enemy;
}

int EnemyPlane::getPostionX() const
{
    return postion_x;
}

void EnemyPlane::setPostionX(int value)
{
    postion_x = value;
}

int EnemyPlane::getPostionY() const
{
    return postion_y;
}

void EnemyPlane::setPostionY(int value)
{
    postion_y = value;
}

void EnemyPlane::updatePostion()
{
    if(isFree){
        return;
    }

    postion_y +=speed;
    enemyRect.moveTo(postion_x,postion_y);

    if(postion_y>GAME_HEIGHT){
        isFree = true;
    }
}

bool EnemyPlane::getIsFree() const
{
    return isFree;
}

void EnemyPlane::setIsFree(bool value)
{
    isFree = value;
}

QRect EnemyPlane::getEnemyRect() const
{
    return enemyRect;
}
